package com.springcloud.openfigen.order.controller;

import com.springcloud.commons.entities.CommonResult;
import com.springcloud.commons.entities.Payment;
import com.springcloud.openfigen.order.service.PaymentFigenService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/feign")
public class FeignOrderController {

    @Resource
    private PaymentFigenService paymentFigenService;

    @RequestMapping(value = "/payment/{id}",method = RequestMethod.GET)
    public CommonResult<Payment> getPaymentById(@PathVariable(value = "id") Long id){
        CommonResult<Payment> payment = paymentFigenService.getPaymentById(id);
        return payment;
    }
    @RequestMapping("/payment/feign/timeout")
    public String paymentFeignTimeOut(){
        // openfeign 默认等待一秒
        String servicePort = paymentFigenService.paymentFeignTimeOut();
        return servicePort;
    }

}
